package com.tensquare.friend.service;

import com.tensquare.friend.dao.NoFriendDao;
import com.tensquare.friend.pojo.NoFriend;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
@Transactional
public class NoFriendService {
    @Autowired
    private NoFriendDao noFriendDao;
    //1.添加对非好友的关注
    public boolean add(String id, String friendid) {
        if (noFriendDao.findByIdAndFriendId(id,friendid) !=null ) return false;
        noFriendDao.save(new NoFriend(id,friendid));
        return true;
    }
    //2.删除对非好友的关注
    public boolean delete(String id, String friendid) {
        if (noFriendDao.findByIdAndFriendId(id,friendid) == null) return false;
        noFriendDao.deleteByIdAndFriendid(id,friendid);
        return true;
    }
}
